package chat.user;

import java.net.Socket;
import java.util.Vector;

import chat.client.ClientMain;
import chat.ui.GroupChatWindow;

public class MessageCreator {
	
	private User user;
	
	public MessageCreator(User u){
		
		this.user =u;
		
	}
	
	public static Message createUpdateGroupMessage(User u){
		
		Message m = new Message(u);
		m.GROUP_UPDATE=true;
		
		return m;
	}
	
	public static Message createTextMessage(String text, User u){
			
		Message m = new Message(text, u);
		
		m.SEND_MESSAGE = true;
		
		return m;
	}
	
	public static Message sendTextMessage(String text, Socket s){
		
		Message m = new Message(text);
		
		m.SEND_MESSAGE = true;
		
		m.setReceiverSocket(s);
		
		return m;
	}
	
	
	public static boolean RequestNewGroup (String group_name, User u){
		
		Message m = new Message (u);
		
		m.setNewGroup(group_name);
		
		m.NEW_GROUP_REQUEST = true;
		
		return ClientMain.addOutMessage(m);
	}
	
	public static boolean AuthRequest(User u){
		
		Message m = new Message (u);
		m.AUTH_REQUEST=true;
		
		return ClientMain.addOutMessage(m);
	}
	
	public static boolean ConnectGroupRequest(String group_name, User u){
		
		Message m = new Message (u);
		
		m.setUserGroup(group_name);
		
		m.CONNECT_TO_GROUP = true;
		
		return ClientMain.addOutMessage(m);
	}
	
	public static Message ConnectGroupRequestResponse(Socket s){
		
		Message m = new Message (s);
		
		m.CONNECT_TO_GROUP = true;
		
		return m;
	}
	
	public static Message AuthRequestResponse (Socket socket){
		
		Message m = new Message(socket);
		
		m.AUTH_REQUEST = true;
		
		return m;
	}
	
	public static Message GroupUpdateRequestResponse (Socket socket, Vector<Group> group_names){
		
		Message m = new Message(socket);
		
		m.setGroupNames(group_names);
		
		m.GROUP_UPDATE = true;
		
		return m;
	}
}
